package com.pet.taglib;


import java.util.ArrayList;
import java.util.List;

import javax.servlet.jsp.JspException;

import org.apache.struts2.views.jsp.StrutsBodyTagSupport;

import com.pet.framework.util.DateUtil;
import com.pet.framework.util.SpringUtil;
import com.pet.server.bo.role.RoleService;
import com.pet.server.po.SysLogger;
public class SysLoggerTag extends StrutsBodyTagSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Integer oid = null;
	private String code = null;

	public Integer getOid() {
		return oid;
	}

	public void setOid(Integer oid) {
		this.oid = oid;
	}

	@Override
	public int doEndTag() throws JspException {
		return EVAL_PAGE;
	}

	@Override
	public int doStartTag() throws JspException {
		try {
		RoleService roleService = SpringUtil.getBean("roleService", RoleService.class);
		List<SysLogger> list = roleService.querySysLogger(oid, code);
		pageContext.getOut().write(html(list));
		} catch (Exception e) {
			e.printStackTrace();
		}

		return SKIP_BODY;
	}
	public String html(List<SysLogger> list){
		StringBuffer sbf = new StringBuffer("<div class=\"main_title\" style=\"background:  #f4f4f4;\">");
		sbf.append("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr>");
		sbf.append("<th width=\"100%\" style=\"border-left:none;text-align: left;font-weight: normal;\"><span style=\"color:#229BC1;font-weight: bold;\">操作日志</span> </th>");
		sbf.append("</tr></table></div>");
		sbf.append("<div class=\"content_main\"><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">");
		for(SysLogger logger:list){
			sbf.append("<tr><td width=\"15%\" style=\"background:#F0F8FF;\" align=\"right\">"+DateUtil.getFormatDate(logger.getCreateTime(), "yyyy-MM-dd HH:mm:ss")+"/td>");
			sbf.append("<td>["+logger.getOperateName()+"] "+logger.getUserName()+" :"+logger.getOperateDesc()+"</td></tr>");
		}
		sbf.append("</table></div>");
		return sbf.toString();
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	
	
	
	

	}
